package logic

import (
	"context"

	"xialou_platform/services/agent/rpc/agentClient"
	"xialou_platform/services/agent/rpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type StoreCheckExistLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewStoreCheckExistLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StoreCheckExistLogic {
	return &StoreCheckExistLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *StoreCheckExistLogic) StoreCheckExist(in *agentClient.StoreCheckExistReq) (*agentClient.StoreCheckExistResp, error) {
	resp := &agentClient.StoreCheckExistResp{
		Exist: false,
	}
	_, err := l.svcCtx.StoreModel.FindByStoreIdAndPlatform(l.ctx, in.StoreId, in.Platform)
	if err != nil {
		return resp, err
	}
	resp.Exist = true
	return resp, nil
}
